﻿package net.wangit.jdbc.sqltype;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

public class ShortSqlType extends NullableSqlType {

	private static final long serialVersionUID = 1L;

	public ShortSqlType() {
	}

	public String get(ResultSet rs, String name) throws SQLException {
		short value = rs.getShort(name);
		if (rs.wasNull())
			return null;
		else
			return Short.toString(value);
	}

	public void setNotNull(PreparedStatement st, String value, int index)
			throws SQLException {
		st.setShort(index, Short.parseShort(value));
	}

	public int sqlType() {
		return Types.SMALLINT;
	}
}
